/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.base.util;

/**
 * 字符串工具
 * 
 * @author Wien(luweien@aliyun.com)
 *
 */
public class StringUtils extends org.springframework.util.StringUtils {

	// Equals
	//-----------------------------------------------------------------------
	/**
	 * <p>Compares two CharSequences, returning {@code true} if they represent
	 * equal sequences of characters.</p>
	 *
	 * <p>{@code null}s are handled without exceptions. Two {@code null}
	 * references are considered to be equal. The comparison is case sensitive.</p>
	 *
	 * <pre>
	 * StringUtils.equals(null, null)   = true
	 * StringUtils.equals(null, "abc")  = false
	 * StringUtils.equals("abc", null)  = false
	 * StringUtils.equals("abc", "abc") = true
	 * StringUtils.equals("abc", "ABC") = false
	 * </pre>
	 *
	 * @see Object#equals(Object)
	 * @param cs1  the first CharSequence, may be {@code null}
	 * @param cs2  the second CharSequence, may be {@code null}
	 * @return {@code true} if the CharSequences are equal (case-sensitive), or both {@code null}
	 * @since 3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
	 */
	public static boolean equals(final CharSequence cs1, final CharSequence cs2) {
		return org.apache.commons.lang3.StringUtils.equals(cs1, cs2);
	}

	/**
	* <p>Compares two CharSequences, returning {@code true} if they represent
	* equal sequences of characters, ignoring case.</p>
	*
	* <p>{@code null}s are handled without exceptions. Two {@code null}
	* references are considered equal. Comparison is case insensitive.</p>
	*
	* <pre>
	* StringUtils.equalsIgnoreCase(null, null)   = true
	* StringUtils.equalsIgnoreCase(null, "abc")  = false
	* StringUtils.equalsIgnoreCase("abc", null)  = false
	* StringUtils.equalsIgnoreCase("abc", "abc") = true
	* StringUtils.equalsIgnoreCase("abc", "ABC") = true
	* </pre>
	*
	* @param str1  the first CharSequence, may be null
	* @param str2  the second CharSequence, may be null
	* @return {@code true} if the CharSequence are equal, case insensitive, or
	*  both {@code null}
	* @since 3.0 Changed signature from equalsIgnoreCase(String, String) to equalsIgnoreCase(CharSequence, CharSequence)
	*/
	public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2) {
		return org.apache.commons.lang3.StringUtils.equalsIgnoreCase(str1, str2);
	}

	/**
	* <p>Compares given <code>string</code> to a CharSequences vararg of <code>searchStrings</code>,
	* returning {@code true} if the <code>string</code> is equal to any of the <code>searchStrings</code>.</p>
	*
	* <pre>
	* StringUtils.equalsAny(null, (CharSequence[]) null) = false
	* StringUtils.equalsAny(null, null, null)    = true
	* StringUtils.equalsAny(null, "abc", "def")  = false
	* StringUtils.equalsAny("abc", null, "def")  = false
	* StringUtils.equalsAny("abc", "abc", "def") = true
	* StringUtils.equalsAny("abc", "ABC", "DEF") = false
	* </pre>
	*
	* @param string to compare, may be {@code null}.
	* @param searchStrings a vararg of strings, may be {@code null}.
	* @return {@code true} if the string is equal (case-sensitive) to any other element of <code>searchStrings</code>;
	* {@code false} if <code>searchStrings</code> is null or contains no matches.
	* @since 3.5
	*/
	public static boolean equalsAny(final CharSequence string, final CharSequence... searchStrings) {
		return org.apache.commons.lang3.StringUtils.equalsAny(string, searchStrings);
	}

	/**
	 * <p>Compares given <code>string</code> to a CharSequences vararg of <code>searchStrings</code>,
	 * returning {@code true} if the <code>string</code> is equal to any of the <code>searchStrings</code>, ignoring case.</p>
	 *
	 * <pre>
	 * StringUtils.equalsAnyIgnoreCase(null, (CharSequence[]) null) = false
	 * StringUtils.equalsAnyIgnoreCase(null, null, null)    = true
	 * StringUtils.equalsAnyIgnoreCase(null, "abc", "def")  = false
	 * StringUtils.equalsAnyIgnoreCase("abc", null, "def")  = false
	 * StringUtils.equalsAnyIgnoreCase("abc", "abc", "def") = true
	 * StringUtils.equalsAnyIgnoreCase("abc", "ABC", "DEF") = true
	 * </pre>
	 *
	 * @param string to compare, may be {@code null}.
	 * @param searchStrings a vararg of strings, may be {@code null}.
	 * @return {@code true} if the string is equal (case-insensitive) to any other element of <code>searchStrings</code>;
	 * {@code false} if <code>searchStrings</code> is null or contains no matches.
	 * @since 3.5
	 */
	public static boolean equalsAnyIgnoreCase(final CharSequence string, final CharSequence... searchStrings) {
		return org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase(string, searchStrings);
	}
}
